﻿<%@ Page Title="" Language="C#" MasterPageFile="~/controlasistencia/Plantilla.Master" AutoEventWireup="true" CodeBehind="bitacora.aspx.cs" Inherits="Presentacion.controlasistencia.bitacora" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="js/plugins/bootstrap-maxlength/bootstrap-maxlength.js"></script>
    <script src="js/jquery.searchabledropdown-1.0.8.min.js"></script>
    <script>
        function sucessMessage(success) {

            Messenger.options = {
                extraClasses: 'messenger-fixed messenger-on-bottom messenger-on-right',
                theme: 'flat'
            }

            Messenger().post({
                message: success,
                type: 'success',
                showCloseButton: true
            });
        }

        function errorMessage(errorMessage) {
            Messenger.options = {
                extraClasses: 'messenger-fixed messenger-on-bottom messenger-on-right',
                theme: 'flat'
            }

            Messenger().post({
                message: errorMessage,
                type: 'error',
                showCloseButton: true
            });
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="contenido" runat="server">
    <form id="frmbitacora" runat="server">
        <div class="row">
            <div class="col-lg-12">
                <div class="page-title">
                    <h1>Registro de Actividad <small>
                        <asp:Label ID="lblCarrera" runat="server" Text="Label"></asp:Label></small></h1>
                    <ol class="breadcrumb">
                        <li><i class="fa"></i><a href="index.aspx" class="tamano-breadcrumbs">Inicio</a>
                        </li>
                        <li class="active tamano-breadcrumbs">Bitácora del Docente</li>
                    </ol>
                </div>
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->

        <div class="row">
            <div class="col-lg-12">
                <div class="portlet portlet-green">
                    <div class="portlet-heading">
                        <div class="portlet-title">
                            <h3>Registro de Actividades </h3>
                        </div>
                        <div class="clearfix">
                        </div>
                    </div>
                    <div class="portlet-body">
                        <div class="form-group">
                            <div class="col-lg-12">

                                <div class="col-lg-6">
                                    <h4>DOCENTES:</h4>
                                    <asp:DropDownList ID="cbxDocentes" runat="server" ClientIDMode="Static" CssClass="form-control" onchange="actualizarMaterias();"></asp:DropDownList>
                                    <input type="hidden" name="name" value="<%Response.Write(Session["CodCarrera"].ToString());%>" id="txtHiden" />
                                </div>
                                <div class="col-lg-6">
                                    <h4>MATERIAS</h4>
                                    <select id="cbxMateria" name="cbxMateria" class="form-control" onchange="actualizarTabla();" style="height: 48px;">
                                    </select>
                                </div>
                            </div>
                            <div class="col-lg-12">
                                <div class="col-lg-6">
                                    <h4>FECHA:</h4>
                                    <asp:TextBox ID="txtfecha" CssClass="form-control" Style="height: 48px;" type="date" runat="server"></asp:TextBox>
                                </div>
                                <div class="col-lg-6">
                                    <h4>TIPO DE ASISTENCIA:</h4>
                                    <asp:DropDownList ID="ddltipo" CssClass="form-control" Style="height: 48px;" runat="server"></asp:DropDownList>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-6 col-md-offset-3">
                                <h4>OBSERVACIÓN:</h4>
                                <textarea id="txtObservaciones" runat="server" data-toggle="textobservacion" rows="2" placeholder="Limit 250 characters." maxlength="250" style="resize: none" class="form-control" enableviewstate="False"></textarea>
                            </div>
                            <div class="clearfix"></div>

                        </div>
                        <div class="form-group">
                            <div class="col-md-6 col-md-offset-3">
                                <asp:Button ID="btnAgregarActividad" runat="server" Text="Agregar Actividad" CssClass="btn btn-green btn-block" OnClick="btnAgregarActividad_Click" />
                            </div>
                            <div class="clearfix"></div>

                        </div>

                    </div>
                </div>

                <div class="portlet portlet-green">
                    <div class="portlet-heading">
                        <div class="portlet-title">
                            <h3>Registro de Actividades </h3>
                        </div>
                        <div class="clearfix">
                        </div>
                    </div>
                    <div class="portlet-body">
                        <div class="table-responsive">
                            <table id="distribuciones" class="table table-striped table-bordered table-hover table-green">
                                <thead>
                                    <tr>
                                        <th>Nro</th>
                                        <th>Materia</th>
                                        <th>Periodo</th>
                                        <th>Tipo</th>
                                        <th>Fecha</th>
                                        <th>Observaciones</th>
                                    </tr>
                                </thead>
                                <tbody id="tablaasignaciones">
                                </tbody>
                            </table>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </form>


</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="script" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {
            $("#cbxDocentes").searchable(
                {
                    maxListSize: 400,                       // if list size are less than maxListSize, show them all
                    maxMultiMatch: 10,                      // how many matching entries should be displayed
                    exactMatch: false,                      // Exact matching on search
                    wildcards: true,                        // Support for wildcard characters (*, ?)
                    ignoreCase: true,                       // Ignore case sensitivity
                    latency: 200,                           // how many millis to wait until starting search
                    warnMultiMatch: 'top {0} matches ...',  // string to append to a list of entries cut short by maxMultiMatch
                    warnNoMatch: 'No existen coincidencias',          // string to show in the list when no entries match
                    zIndex: 'auto'                          // zIndex for elements generated by this plugin
                });
        });
        ///version del browser
        jQuery.browser = {};
        (function () {
            jQuery.browser.msie = false;
            jQuery.browser.version = 0;
            if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) {
                jQuery.browser.msie = true;
                jQuery.browser.version = RegExp.$1;
            }
        })();
        //Max Length Plugin Initialization and Custom Functions
        $(document).ready(function () {

            $('textarea#contenido_txtObservaciones').maxlength({
                alwaysShow: true,
                warningClass: "label green",
                limitReachedClass: "label orange"
            });
        });

        function actualizarTabla() {
            var idmateria = document.getElementById('cbxMateria').value;
            if (idmateria != "") {
                $.ajax({
                    type: "POST",
                    url: "bitacora.aspx/materias",
                    data: "{ _idDistribucion:" + idmateria + ", _idPeriodo: <% Response.Write(Session["periodo"].ToString());%>}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (response) {
                        $("#tablaasignaciones").empty();
                        console.log(response);

                        $("#tablaasignaciones").append(response.d);

                    },
                    statusCode: {
                        404: function () {
                            errorMessage("Pagina no encontrada");
                        },
                        500: function () {
                            errorMessage("Problemas con el servidor.");
                        }
                    },
                });
            }
            else {
                $("#cbxMateria").empty();

            }
        }

        function actualizarMaterias() {
            var idDocente = document.getElementById('cbxDocentes').value;
            var idCarrera = document.getElementById('txtHiden').value;
            if (idDocente != "") {
                $.ajax({
                    type: "POST",
                    url: "materiasAjax.aspx/docentesm",
                    data: "{ _idCarrera:" + idCarrera + ", _idDocente:" + idDocente + "}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (response) {
                        $("#cbxMateria").empty();
                        $("#cbxMateria").append("<option value='0'>Seleccione la materia correspondiente.</option>");
                        $.each(response.d, function (key, value) {
                            $('#cbxMateria').append($("<option></option>").val(value.idDistribucion).html(value.Nombre));
                        });
                    },
                    statusCode: {
                        404: function () {
                            errorMessage("Pagina no encontrada");
                        },
                        500: function () {
                            errorMessage("Problemas con el servidor.");
                        }
                    },
                });
            }
            else {
                $("#cbxMateria").empty();
                $("#cbxMateria").append("<option value='0'>Seleccione un docente.</option>");
            }
        }
        $(document).ready(function () {
            actualizarMaterias();
            actualizarTabla();
        });
    </script>
</asp:Content>
